1. Field of Invention
The present invention relates generally to computing systems which include virtual machines. More particularly, the present invention relates to compactly representing parameter-passing and value-returning type information of a method.
2. Description of the Related Art
Within an environment which includes a virtual machine, e.g., a Java(trademark) virtual machine developed by Sun Microsystems, Inc. of Palo Alto, Calif., classes are often loaded and unloaded in the process of executing the virtual machine, as will be understood by those skilled in the art. The format of the class files may vary depending upon the requirements of the environment. By way of example, in a Java(trademark) virtual machine environment, the class files may include files which are in a Java(trademark) class format as is described in The Java(trademark) Virtual Machine Specification by Tim Lindholm and Frank Yellin (ISBN 0-201-63452-X), which is incorporated herein by reference.
In a Java(trademark) class file format, substantially all references to methods, which may be considered to be routines or subroutines, have an associated type signature. The type signature may be an external signature, and is arranged to provide parameter types expected by the method, as well as the return type of the method. A type signature is typically represented as a sequence of 8-bit characters, and often consumes a relatively large amount of memory space. The sequence generally includes a method-type beginning marker, parameters which are each represented by a character, a separater character, and a character which represents the return type. In some situations, as for example when types are class types or arrays, the type signature may occupy additional memory space to provide either the name of a class or the depth of an array.
Many standard implementations of a virtual machine, e.g., a Java(trademark) virtual machine, translate a type or external signature representations into internal data structures which are used by the virtual machine. The data structures associated with type signature representations are generally not of a fixed length, e.g., the data structures associated with type signature representations are strings of a variable length. The length of the data structures is not of a fixed length due at least in part to the fact that the number of parameters in a type signature may vary. As such, the data structures associated with type signature representations are often inefficient. That is, efficient data structures are typically of fixed length, and the data structures associated with type signature representations are of variable length. As a result, standard implementations of a virtual machine often include the use of a pointer, e.g., a 4-byte pointer, to the variable-length signature. Such a pointer may be independently allocated in memory. The use of such a pointer further increases the amount of memory space that is used within the virtual machine environment.
By translating type signature representation into internal data structures and, further, by implementing pointers to a variable-length signature, when a virtual machine requires the comparison of compare two signatures, the virtual machine must implement a variable-length, character-by-character comparison. Such a comparison is time-consuming and, therefore, often degrades the performance of the virtual machine.
In some implementations of a virtual machine, e.g., a Java(trademark) virtual machine, in order to avoid the need to perform variable-length, character-by-character comparison, a table which lists substantially all method signatures may be used. Specifically, such a table may be used to effectively xe2x80x9clook upxe2x80x9d all new signatures to determine if the new signatures have a match within the table. Once a new signature is looked up, a comparison of signatures involves a character-pointer comparison. Although such a comparison is more efficient that a variable-length, character-by-character comparison, the signatures still often require a significant amount of memory.
Therefore, what is desired is an efficient method for implementing and processing method signatures. More particularly, what is needed is a method and an apparatus for reducing the amount of memory space and the amount of overhead associated with implementing and processing method signatures with respect to a virtual machine.
The present invention relates to creating and implementing compacted method signatures from method signature representations in Java(trademark) class files. The use of compacted signatures reduces the amount of memory space occupied by the signatures and, further, improve the efficiency with which a virtual machine may operate. According to one aspect of the present invention, a method a method for creating a compact representation of a method signature using a virtual machine includes creating 4-bit representations for each of a first parameter, a separator, and a return type included in the method signature. Once the 4-bit representation are created, the representations are packed into a word. In one embodiment, the word is a 32-bit word. In such an embodiment, the 32-bit word may be a 32-bit integer.